import { Module } from '@nestjs/common';
import { DeviceMsgDispatchService } from './device-msg-dispatch.service';
import { ConfigureModule, ConfigureService } from '@app/configure';
import { CacheModule } from '@nestjs/cache-manager';
import { AliIotSubscribeClientModule } from 'apps/ali-iot-subscribe-client/src/ali-iot-subscribe-client.module';
import { MqttClientModule } from 'apps/mqtt-client/src/mqtt-client.module';
import { redisStore } from 'cache-manager-ioredis-yet';

@Module({
  imports: [
    ConfigureModule,
    AliIotSubscribeClientModule,
    CacheModule.registerAsync({
      imports : [ConfigureModule],
      inject : [ConfigureService],
      useFactory : (config:ConfigureService) => {
        return {
          store: redisStore,
          ...config.get('cache')
        }
      }
    }),

    MqttClientModule
  ],
  providers: [DeviceMsgDispatchService],
})
export class DeviceMsgDispatchModule {}
